package com.wei.controller.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wei.blog.common.dto.BlogPage;
import com.wei.blog.common.help.UserHelp;
import com.wei.service.InvitationService;
import com.wei.vo.IndexDataVo;
import com.wei.vo.UserToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class IndexController {
    @Autowired
    private InvitationService invitationService;
    @Autowired
    private UserHelp userHelp;

    @GetMapping("/")
    String index(BlogPage<IndexDataVo> blogPage, ModelMap map) {
        blogPage.setSize(2);
        blogPage = (BlogPage) invitationService.indexPage(blogPage);
        blogPage.setPath("/");
        map.put("page", blogPage);
        UserToken loginUser = userHelp.get();
        map.put("loginUser", loginUser);
        return "index";
    }


    @ResponseBody
    @GetMapping("/index/{orderMode}")
    String New(@PathVariable Integer orderMode){
        if (orderMode==0){

        }
        return "";
    }
}
